package fr.aprr.odyssee.server.domain.dao;

import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.Statement;

public class ConnectionConfig {
 
	public static String testConnection(String niveau){
		String nom = null;
		String meta = null; 
		try {
			
			Class.forName("org.postgresql.Driver");
		      System.out.println("Driver O.K.");
		      String url = "jdbc:postgresql://localhost:5432/odyssee";
		      String user = "odyssee";
		      String passwd = "odyssee";
		      Connection conn = DriverManager.getConnection(url, user, passwd);
		      System.out.println("Connexion effective !");  
		      
		      Statement state = conn.createStatement();
		      ResultSet result = state.executeQuery("SELECT * FROM ody$conf_user");
		      ResultSetMetaData resultMeta = result.getMetaData();
		      

		      meta = resultMeta.getColumnName(1);
		} 
		
		catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return meta;
		
	}
}
